home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / usr / include / malloc.h < prev    next >
C/C++ Source or Header  |  2009-10-07  |  6KB  |  181 lines

  1. /* Prototypes and definition for malloc implementation.
  2.    Copyright (C) 1996, 1997, 1999, 2000, 2002-2004, 2005, 2007, 2009
  3.    Free Software Foundation, Inc.
  4.    This file is part of the GNU C Library.
  5.  
  6.    The GNU C Library is free software; you can redistribute it and/or
  7.    modify it under the terms of the GNU Lesser General Public
  8.    License as published by the Free Software Foundation; either
  9.    version 2.1 of the License, or (at your option) any later version.
  10.  
  11.    The GNU C Library is distributed in the hope that it will be useful,
  12.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14.    Lesser General Public License for more details.
  15.  
  16.    You should have received a copy of the GNU Lesser General Public
  17.    License along with the GNU C Library; if not, write to the Free
  18.    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  19.    02111-1307 USA.  */
  20.  
  21. #ifndef _MALLOC_H
  22. #define _MALLOC_H 1
  23.  
  24. #include <features.h>
  25. #include <stddef.h>
  26. #include <stdio.h>
  27. # define __malloc_ptr_t  void *
  28.  
  29. /* Used by GNU libc internals. */
  30. #define __malloc_size_t size_t
  31. #define __malloc_ptrdiff_t ptrdiff_t
  32.  
  33. #ifdef __GNUC__
  34.  
  35. # define __MALLOC_P(args)    args __THROW
  36. /* This macro will be used for functions which might take C++ callback
  37.    functions.  */
  38. # define __MALLOC_PMT(args)    args
  39.  
  40. #else    /* Not GCC.  */
  41.  
  42. # define __MALLOC_P(args)    args
  43. # define __MALLOC_PMT(args)    args
  44.  
  45. #endif    /* GCC.  */
  46.  
  47.  
  48. __BEGIN_DECLS
  49.  
  50. /* Allocate SIZE bytes of memory.  */
  51. extern void *malloc __MALLOC_P ((size_t __size)) __attribute_malloc__ __wur;
  52.  
  53. /* Allocate NMEMB elements of SIZE bytes each, all initialized to 0.  */
  54. extern void *calloc __MALLOC_P ((size_t __nmemb, size_t __size))
  55.        __attribute_malloc__ __wur;
  56.  
  57. /* Re-allocate the previously allocated block in __ptr, making the new
  58.    block SIZE bytes long.  */
  59. /* __attribute_malloc__ is not used, because if realloc returns
  60.    the same pointer that was passed to it, aliasing needs to be allowed
  61.    between objects pointed by the old and new pointers.  */
  62. extern void *realloc __MALLOC_P ((void *__ptr, size_t __size))
  63.        __attribute_warn_unused_result__;
  64.  
  65. /* Free a block allocated by `malloc', `realloc' or `calloc'.  */
  66. extern void free __MALLOC_P ((void *__ptr));
  67.  
  68. /* Free a block allocated by `calloc'. */
  69. extern void cfree __MALLOC_P ((void *__ptr));
  70.  
  71. /* Allocate SIZE bytes allocated to ALIGNMENT bytes.  */
  72. extern void *memalign __MALLOC_P ((size_t __alignment, size_t __size))
  73.        __attribute_malloc__ __wur;
  74.  
  75. /* Allocate SIZE bytes on a page boundary.  */
  76. extern void *valloc __MALLOC_P ((size_t __size))
  77.        __attribute_malloc__ __wur;
  78.  
  79. /* Equivalent to valloc(minimum-page-that-holds(n)), that is, round up
  80.    __size to nearest pagesize. */
  81. extern void * pvalloc __MALLOC_P ((size_t __size))
  82.        __attribute_malloc__ __wur;
  83.  
  84. /* Underlying allocation function; successive calls should return
  85.    contiguous pieces of memory.  */
  86. extern void *(*__morecore) __MALLOC_PMT ((ptrdiff_t __size));
  87.  
  88. /* Default value of `__morecore'.  */
  89. extern void *__default_morecore __MALLOC_P ((ptrdiff_t __size))
  90.        __attribute_malloc__;
  91.  
  92. /* SVID2/XPG mallinfo structure */
  93.  
  94. struct mallinfo {
  95.   int arena;    /* non-mmapped space allocated from system */
  96.   int ordblks;  /* number of free chunks */
  97.   int smblks;   /* number of fastbin blocks */
  98.   int hblks;    /* number of mmapped regions */
  99.   int hblkhd;   /* space in mmapped regions */
  100.   int usmblks;  /* maximum total allocated space */
  101.   int fsmblks;  /* space available in freed fastbin blocks */
  102.   int uordblks; /* total allocated space */
  103.   int fordblks; /* total free space */
  104.   int keepcost; /* top-most, releasable (via malloc_trim) space */
  105. };
  106.  
  107. /* Returns a copy of the updated current mallinfo. */
  108. extern struct mallinfo mallinfo __MALLOC_P ((void));
  109.  
  110. /* SVID2/XPG mallopt options */
  111. #ifndef M_MXFAST
  112. # define M_MXFAST  1    /* maximum request size for "fastbins" */
  113. #endif
  114. #ifndef M_NLBLKS
  115. # define M_NLBLKS  2    /* UNUSED in this malloc */
  116. #endif
  117. #ifndef M_GRAIN
  118. # define M_GRAIN   3    /* UNUSED in this malloc */
  119. #endif
  120. #ifndef M_KEEP
  121. # define M_KEEP    4    /* UNUSED in this malloc */
  122. #endif
  123.  
  124. /* mallopt options that actually do something */
  125. #define M_TRIM_THRESHOLD    -1
  126. #define M_TOP_PAD           -2
  127. #define M_MMAP_THRESHOLD    -3
  128. #define M_MMAP_MAX          -4
  129. #define M_CHECK_ACTION      -5
  130. #define M_PERTURB        -6
  131. #define M_ARENA_TEST        -7
  132. #define M_ARENA_MAX        -8
  133.  
  134. /* General SVID/XPG interface to tunable parameters. */
  135. extern int mallopt __MALLOC_P ((int __param, int __val));
  136.  
  137. /* Release all but __pad bytes of freed top-most memory back to the
  138.    system. Return 1 if successful, else 0. */
  139. extern int malloc_trim __MALLOC_P ((size_t __pad));
  140.  
  141. /* Report the number of usable allocated bytes associated with allocated
  142.    chunk __ptr. */
  143. extern size_t malloc_usable_size __MALLOC_P ((void *__ptr));
  144.  
  145. /* Prints brief summary statistics on stderr. */
  146. extern void malloc_stats __MALLOC_P ((void));
  147.  
  148. /* Output information about state of allocator to stream FP.  */
  149. extern int malloc_info (int __options, FILE *__fp);
  150.  
  151. /* Record the state of all malloc variables in an opaque data structure. */
  152. extern void *malloc_get_state __MALLOC_P ((void));
  153.  
  154. /* Restore the state of all malloc variables from data obtained with
  155.    malloc_get_state(). */
  156. extern int malloc_set_state __MALLOC_P ((void *__ptr));
  157.  
  158. /* Called once when malloc is initialized; redefining this variable in
  159.    the application provides the preferred way to set up the hook
  160.    pointers. */
  161. extern void (*__malloc_initialize_hook) __MALLOC_PMT ((void));
  162. /* Hooks for debugging and user-defined versions. */
  163. extern void (*__free_hook) __MALLOC_PMT ((void *__ptr,
  164.                     __const __malloc_ptr_t));
  165. extern void *(*__malloc_hook) __MALLOC_PMT ((size_t __size,
  166.                          __const __malloc_ptr_t));
  167. extern void *(*__realloc_hook) __MALLOC_PMT ((void *__ptr, size_t __size,
  168.                           __const __malloc_ptr_t));
  169. extern void *(*__memalign_hook) __MALLOC_PMT ((size_t __alignment,
  170.                            size_t __size,
  171.                            __const __malloc_ptr_t));
  172. extern void (*__after_morecore_hook) __MALLOC_PMT ((void));
  173.  
  174. /* Activate a standard set of debugging hooks. */
  175. extern void __malloc_check_init __MALLOC_P ((void));
  176.  
  177.  
  178. __END_DECLS
  179.  
  180. #endif /* malloc.h */
  181.